package com.dsideal.cloud.cas.client.config;

import com.dsideal.cloud.auth.core.interceptor.BaseContextInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class ContextConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private BaseContextInterceptor baseContextInterceptor;

    @Bean
    public BaseContextInterceptor getUserAuthRestInterceptor() {
        return new BaseContextInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         *
         * 此处注释原因：
         * 本服务是用来获取token信息
         * 此拦截器是用来从token中获取用户信息，并且在本服务中不利用BaseContextHolder获取信息
         * 没必要
         *
         */

//        registry.addInterceptor(baseContextInterceptor);
        super.addInterceptors(registry);
    }
}
